<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*"%>
<%@ page import="xml.response.*"%>
<%@ page import="requestInterFace.Handle.*"%>
<%@ page import="xml.root"%>
<%@ page import="util.print.printLogCat"%>
<%@ page import="org.sql.table.*"%>
<%@ page import="xml.var"%>
<%@ page import="java.util.Vector"%>
<%@ page import="java.util.Enumeration"%>
<%@ page import="jqgrid.jqgrid"%>
<%@ page import="util.check"%>
<%@ include file="../../util/paramPrint.jsp" %>
<%@ page trimDirectiveWhitespaces="true" %> 
<%   

    /*********** jqgrid ******************/
		jqgrid jq=new jqgrid();
		jq.setRows(request.getParameter(jqgrid._rows));
		jq.setSord(request.getParameter(jqgrid._sord));
		jq.setSortname(request.getParameter(jqgrid._sortname));
		jq.setPage(request.getParameter(jqgrid._page));
		jq.setOper(request.getParameter(jqgrid._oper));
		jq.setSearch(request.getParameter(jqgrid._search));
		/*************************************/
		
		String userID=(String)session.getAttribute("User_ID");
		String userType=(String)session.getAttribute("User_Type");
		
		String Order_Products = request.getParameter("Order_Products");
		String startTime = request.getParameter("startTime");
		String endTime = request.getParameter("endTime");
		String User_ID = request.getParameter("User_ID");
		String UP_ID = request.getParameter("UP_ID");
		String Grop = request.getParameter("Grop");
		String Product_Type = request.getParameter("Product_Type");
			if(UP_ID!=null&&(!UP_ID.equals(""))){
			UP_ID=java.net.URLDecoder.decode(UP_ID,"UTF-8");
		}
			if(User_ID!=null&&(!User_ID.equals(""))){
			User_ID=java.net.URLDecoder.decode(User_ID,"UTF-8");
			}
		if(!check.checkString(Grop)){
		//如果grop没哟默认为 Order_Products
		Grop="Order_Products";
		}
		root root=new root();
		if(!check.checkString(Order_Products)){
		root.setStatus("false");
		root.setMsg("请输入正确的产品ID");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
		
		orderStat orderStat=new orderStat();
		orderinfo1_1 totleOrderNum=new orderinfo1_1();
		if(Grop.equals("Product_Type")){
		if(!check.checkString(Product_Type)){
		root.setStatus("false");
		root.setMsg("请输入正确的产品类型");
		PrintWriter pw = response.getWriter();
		pw.println(root.getXmlString());
		pw.flush();
		return ;
		}
	
		Order_Products="";
		totleOrderNum.addequwhile("Product_Type", "=", Product_Type);
		}
		totleOrderNum=orderStat.StatProductSaleNum(totleOrderNum,Order_Products,startTime,endTime,User_ID,UP_ID,"",Grop);
		int totleNum=0;
		if(totleOrderNum.getTableFactroy().size()>0){
		orderinfo1_1 order1=(orderinfo1_1)totleOrderNum.getTableFactroy().elementAt(0);
		//获取产品总销售数量
		totleNum=(int)Float.parseFloat(order1.getFieldsStr("Sum(Product_Num)"));
		}
		
		
		orderinfo1_1 totleOrderBackNum=new orderinfo1_1();
		if(Grop.equals("Product_Type")){
		Order_Products="";
		totleOrderBackNum.addequwhile("Product_Type", "=", Product_Type);
		}
		totleOrderBackNum=orderStat.StatProductSaleNum(totleOrderBackNum,Order_Products,startTime,endTime,User_ID,UP_ID,"5",Grop);
		int totleBackNum=0;
		if(totleOrderBackNum.getTableFactroy().size()>0){
		orderinfo1_1 order2=(orderinfo1_1)totleOrderBackNum.getTableFactroy().elementAt(0);
		//获取产品总销售数量
		totleBackNum=(int)Float.parseFloat(order2.getFieldsStr("Sum(Product_Num)"));
		}
		root.setStatus("true");
		float l=(float)totleBackNum/totleNum;
		root.setMsg("销售数量为:"+totleNum+"退货量为:"+totleBackNum+"退货类率为:"+l);
		//printLogCat.printlnWriter(root.getXmlString());
		String rep=root.getXmlString();
%>
<%=rep%>





